﻿using Baula.TextGen.ActiveTemplating.Tokenizer.TokenParsers;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Baula.TextGen.ActiveTemplating.Tests.Tokenizer.TokenParsers
{
    [TestClass]
    public abstract class TokenParserTestsBase
    {
        protected ITokenParser _parser;

        [TestInitialize]
        public void TestInitialize()
        {
            _parser = CreateParser();
        }

        protected abstract ITokenParser CreateParser();

        protected void SetInitialContent(string initialContent)
        {
            StuffParserWith(initialContent);
        }

        protected void SetContentAndClose(string content)
        {
            SetInitialContent(content);
            CloseToken(_parser);
        }

        protected abstract void CloseToken(ITokenParser parser);

        private void StuffParserWith(string initialString)
        {
            foreach (var c in initialString)
            {
                _parser.Append(c);
            }
        }
    }
}